#ifndef __UID_HPP__
#define __UID_HPP__

#include <string>
#include <sstream>

class Uid
{
public:
    static std::string HEX;
    static size_t IDX;
    static std::string gen( size_t len ) {
        std::string str;
        while ( len-- ) str += Uid::HEX[rand() % Uid::IDX];
        return str;
    }
    static std::string get0x( size_t x ) {
        std::stringstream ss;
        ss << rand() % ( rand() % x + 1 );
        return ss.str();
    }
    //static getuid() {
    //    return ( "" + ( new date().gettime() ) + uid.get0x( 9999 ) );
    //}
};

std::string Uid::HEX = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
size_t Uid::IDX = 36;

//
//class Uid {
//    static gen( len ) {
//        var str = '', num = len || 11;
//        while ( num-- ) str += Uid.HEX[Math.random() * 36 | 0];
//        return str;
//    }
//    static get0x( x ) {
//        return Math.floor( Math.random() * x + 1 );
//    }
//    static getUid() {
//        return ( "" + ( new Date().getTime() ) + Uid.get0x( 9999 ) );
//    }
//};
//Uid.IDX = 36, Uid.HEX = '';
//while ( Uid.IDX-- ) Uid.HEX += Uid.IDX.toString( 36 );

#endif // !__UID_HPP__
